package com.smartinput.auth.controller

import com.mensanyun.kotool.util.executeQueryWithTry
import com.mensanyun.kotool.util.executeWithResult
import com.smartinput.auth.application.dto.*
import com.smartinput.auth.application.service.AuthService
import jakarta.validation.Valid
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("/api/auth")
class AuthController(
    private val authService: AuthService
) {

    @PostMapping("/register")
    fun register(@Valid @RequestBody request: RegisterRequest) = executeWithResult {
        authService.register(request)
    }

    @PostMapping("/login")
    fun login(@Valid @RequestBody request: LoginRequest) = executeWithResult {
        authService.login(request)
    }

    @GetMapping("/validate")
    fun validateToken() = executeQueryWithTry {
        authService.validateCurrentToken()
    }

    @GetMapping("/test")
    fun test() = executeQueryWithTry {
        "Auth Test"
    }
} 